home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2 Examples.sit
/
Raven 1.2 Examples
/
Quill
/
Source
/
DocWindow.cpp
< prev
next >
Wrap
Text File
|
1997-02-20
|
4KB
|
169 lines
/*
* File: DocWindow.h
* Summary: Quill's document window.
* Written by: Jesse Jones
*
* Copyright ゥ 1996 Jesse Jones.
* For conditions of distribution and use, see copyright notice in ZTypes.h
*
* Change History (most recent first):
*
* <-> 8/09/96 JDJ Created
*/
#include "DocWindow.h"
#include <Map.h>
#include <ZMenu.h>
#include <ZMenuBar.h>
#include <ZMiscUtils.h>
#include <ZProfiler.h>
#include "Document.h"
#include "ResourceTable.h"
// ===================================================================================
// class CDocWindow
// ===================================================================================
static TReanimatorRegister<CDocWindow> sDocWindowRegistrar;
//---------------------------------------------------------------
//
// CDocWindow::~CDocWindow
//
//---------------------------------------------------------------
CDocWindow::~CDocWindow()
{
}
//---------------------------------------------------------------
//
// CDocWindow::CDocWindow
//
//---------------------------------------------------------------
CDocWindow::CDocWindow()
{
}
//---------------------------------------------------------------
//
// CDocWindow::Create [static]
//
//---------------------------------------------------------------
MReanimatable* CDocWindow::Create(MReanimatable*)
{
return new CDocWindow;
}
#pragma mark ハ
//---------------------------------------------------------------
//
// CDocWindow::OnReanimated
//
//---------------------------------------------------------------
void CDocWindow::OnReanimated()
{
Inherited::OnReanimated();
CResourceTable* table = dynamic_cast<CResourceTable*>(this->FindSubPane("Resource Table"));
ASSERT(table != nil);
this->SetLatentTarget(table);
CCustomClasses* classes = dynamic_cast<CDocument*>(mDoc)->GetCustomPanes();
classes->AddListener(this);
}
//---------------------------------------------------------------
//
// CDocWindow::OnActivating
//
//---------------------------------------------------------------
void CDocWindow::OnActivating()
{
Inherited::OnActivating();
this->UpdateCustomClassMenu();
}
//---------------------------------------------------------------
//
// CDocWindow::OnBroadcast (SDocumentMessage)
//
//---------------------------------------------------------------
void CDocWindow::OnBroadcast(const SDocumentMessage& mesg)
{
ASSERT(mesg.document == mDoc);
switch (mesg.change) {
case kChangedDocument:
// do nothing
break;
case kOpenedDocument:
case kSavedDocument:
case kRevertedDocument:
this->Invalidate();
// fall through
default:
Inherited::OnBroadcast(mesg);
}
}
//---------------------------------------------------------------
//
// CDocWindow::OnBroadcast (CCustomClasses*)
//
//---------------------------------------------------------------
void CDocWindow::OnBroadcast(CCustomClasses* const& mesg)
{
#pragma unused(mesg)
if (TDocWindow::GetFront() == this)
this->UpdateCustomClassMenu();
}
#pragma mark ハ
//---------------------------------------------------------------
//
// CDocWindow::UpdateCustomClassMenu
//
//---------------------------------------------------------------
void CDocWindow::UpdateCustomClassMenu()
{
TMenu* menu = TMenuBar::Instance()->GetMenuByID(248);
ASSERT(menu != nil);
// Remove the old items.
while (menu->GetCount() > 2)
menu->RemoveItem(0);
// Add the new items.
CCustomClasses* classes = dynamic_cast<CDocument*>(mDoc)->GetCustomPanes();
if (classes->GetNumClasses() > 0) {
menu->InsertItem("(-", 0, kNothingCmd);
const CCustomClasses::ClassTable* table = classes->GetTable();
CCustomClasses::ClassTable::const_iterator iter = table->begin();
while (iter != table->end()) {
CCustomClasses::ClassEntry entry = *iter++;
menu->InsertSortedItem(entry.first, 0, menu->GetCount() - 3, entry.first);
}
}
TMenuBar::Invalidate();
}